package cn.school.attendance.classes.dao;

import cn.school.attendance.classes.entity.ClassesAttendanceDo;
import cn.school.attendance.classes.vo.ClassesAttendanceVo;
import cn.school.attendance.classes.vo.ClassesAttendanceInfoPageParam;
import cn.school.attendance.classes.vo.LeaveAndNotArrivedStudentInfoVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 班级学生考勤信息
 */
@Mapper
public interface ClassesAttendanceInfoMapper extends BaseMapper<ClassesAttendanceDo> {

    //获取班级信息
    ClassesAttendanceVo getClassAttendanceInfo(ClassesAttendanceInfoPageParam classesAttendanceInfoPageParam);

    //分页查询班级学生考勤信息
    List<ClassesAttendanceDo> getStudentAttendanceList(ClassesAttendanceInfoPageParam classesAttendanceInfoPageParam);

    //更新学生考勤状态
    void updateAttendanceInfoStatus(ClassesAttendanceDo classesAttendanceInfo);

    //批量插入考勤信息
    void insertBatch(@Param("attendanceList")List<ClassesAttendanceDo> attendanceInfoList);

    //批量更新考勤信息
    void updateBatch(@Param("attendanceList")List<ClassesAttendanceDo> classesAttendanceDos);

    //获取班级学生考勤信息总条数
    int getStudentAttendancePageListCount(ClassesAttendanceInfoPageParam classesAttendanceInfoPageParam);

    List<ClassesAttendanceDo> getAllStudentAttendanceListByClassId(@Param("classId") Long classId,@Param("attendanceDate") String attendanceDate);

    @Select("SELECT tdb.use_student_id FROM t_student_info si " +
            "JOIN t_dormitory_berth tdb ON si.id = tdb.use_student_id " +
            "WHERE class_id = #{classId}")
    List<Long> getStudentIdsByClassId(Long classId);

    List<LeaveAndNotArrivedStudentInfoVo> getLeaveStudentInfoList(ClassesAttendanceInfoPageParam param);
    //根据班级ID查询已请假的学生id
    List<Long> getLeaveStudentIdList(ClassesAttendanceInfoPageParam classesAttendanceInfoPageParam);

    //根据班级ID查询已请假的学生id
    List<Long> getSelfLeaveStudentIdList(ClassesAttendanceInfoPageParam classesAttendanceInfoPageParam);
    //获取未到学生列表
    List<LeaveAndNotArrivedStudentInfoVo> getNotArrivedStudentInfoList(ClassesAttendanceInfoPageParam classesAttendanceInfoPageParam);
}
